from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
db = SQLAlchemy()
migrate = Migrate()

def init_databases(app: Flask):
    db.init_app(app)
    with app.app_context():
        try:
            db.engine.connect()
        except Exception as e:
            exit(f"数据库连接失败: {e}")

def init_migrate(app: Flask):
    migrate.init_app(app, db)
